
let path = require("path");
let webpack = require("webpack");
let HtmlWebpackPlugin = require("html-webpack-plugin")
let HotModuleReplacementPlugin = require('webpack/lib/HotModuleReplacementPlugin');

module.exports = {
    mode: "development",
    entry:"./src/index.js",
    output: {
        filename: "[name].js",
        path: path.resolve(__dirname, "dist"),
        hotUpdateGlobal:'webpackHotUpdate' //仅在target设置为时'web'使用，它使用JSONP加载热更新。JSONP 函数用于异步加载热更新块。
    },
    devServer:{
        hot:true, //支持热更新
        port:8080,
        contentBase:path.join(__dirname,'static')
    },
    plugins: [
        new HtmlWebpackPlugin({
            template:'./public/index.html'
        }),
        new HotModuleReplacementPlugin() //此处可写可不写，因为如果devServer.hot==true的话，webpack会自动帮你添加此插件
    ]
}